<!--
 * @Author: TANGB02 13233582+Ace-Tang@user.noreply.gitee.com
 * @Date: 2024-01-21 10:30:45
 * @LastEditors: TANGB02 13233582+Ace-Tang@user.noreply.gitee.com
 * @LastEditTime: 2024-03-15 09:24:42
 * @FilePath: \ycq\ycq\ycq1.0\src\pages\home\home.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<!--
 * @Author: TANGB02 13233582+Ace-Tang@user.noreply.gitee.com
 * @Date: 2024-01-21 10:30:45
 * @LastEditors: TANGB02 13233582+Ace-Tang@user.noreply.gitee.com
 * @LastEditTime: 2024-03-10 11:26:37
 * @FilePath: \ycq\ycq\ycq1.0\src\pages\home\home.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <Loaded v-if="isLoading" />

  <div class="wrap" v-if="!isLoading">
    <!-- 头部 -->
    <div class="header">
      <div class="container1">
        <!-- 头像 -->

        <img
          src="../../imgs/header.png"
          alt=""
          class="headerImg"
          @mouseenter="handleMouseEnter"
          @mouseleave="handleMouseLeave"
        />

        <div
          class="myDetails"
          ref="myDetails"
          @mouseenter="handleMouseEnter"
          @mouseleave="handleMouseLeave"
        >
          <div class="logined" v-if="LocalCatch.getToken('roles') === 'user'">
            <h2>{{ LocalCatch.getToken("userName") }}</h2>
            <a href="/personal"
              ><img src="../../imgs/loginOut.png" alt="" />个人中心</a
            >
            <a style="cursor: pointer"
              ><img src="../../imgs/loginOut.png" alt="" />领养中心</a
            >
            <a @click="exit" style="cursor: pointer">
              <img src="../../imgs/loginOut.png" alt="" />退出</a
            >
          </div>
          <div class="noLogin" v-if="!getIsLogin()">
            <div class="notice">
              <p class="til">登录后您可以:</p>
              <p class="til-a">
                <img
                  src="../../imgs/comments.png"
                  alt=""
                  class="til-b"
                />留言评论
              </p>
              <p class="til-a">
                <img
                  src="../../imgs/comments.png"
                  alt=""
                  class="til-b"
                />领养猫猫
              </p>
              <p class="til-a">
                <img
                  src="../../imgs/comments.png"
                  alt=""
                  class="til-b"
                />爱心捐赠
              </p>
              <p class="til-a">
                <img
                  src="../../imgs/comments.png"
                  alt=""
                  class="til-b"
                />购买周边商品
              </p>
            </div>
            <span @click="login">立即登录 </span>
          </div>
          <div class="logined" v-if="LocalCatch.getToken('roles') === 'admin'">
            <a href="/manager/managerDefaut"
              ><img src="../../imgs/loginOut.png" alt="" />管理中心</a
            >

            <a @click="exit" style="cursor: pointer">
              <img src="../../imgs/loginOut.png" alt="" />退出</a
            >
          </div>
        </div>

        <a
          href=""
          style="
            height: 35px;
            line-height: 35px;
            font-size: 14px;
            margin-top: 5px;
            color: #a49c96;
          "
        >
          <span>Enligh</span>
          &nbsp;&nbsp;|&nbsp;&nbsp;
          <span style="color: #52443f">中文</span>
        </a>
      </div>
      <div class="container2">
        <a href="./" class="logo">
          <!-- <img src="../../imgs/logo.png" alt="" /> -->
          <div class="title"><span class="txt">悦</span>猫圈</div>
        </a>
        <div class="search">
          <a-input
            type="text"
            name="s"
            placeholder="请输入您想要搜索的内容"
            class="text"
            v-model:value="search"
          />

          <img
            src="../../imgs/search.png"
            alt=""
            class="searchBtn"
            @click="handleSearch"
          />
        </div>
      </div>
    </div>
    <!-- 导航 -->
    <div class="container">
      <div class="nav">
        <ul>
          <li><a href="/">首页</a></li>
          <li class="about">
            <a href="javascript:;">关于我们</a>
            <span class="crow"> </span>
            <div class="menu2">
              <p @click="toNavDetails">简介</p>
              <p @click="toLatestNews">最新消息</p>
            </div>
          </li>
          <li @click=""><span class="items">宠物保护</span></li>
          <li><span class="items">宠物与领养人</span></li>
          <li @click="tolAdoptMsg"><span class="items">领养须知</span></li>
          <li @click="tolCommonSense"><span class="items">小常识</span></li>
          <li><span class="items">寄养服务</span></li>
          <li><span class="items">捐助</span></li>
          <li @click="handleAbout"><span class="items">联系我们</span></li>
        </ul>
      </div>
    </div>
    <!-- 登录框 -->
    <Login :lopen="open" @handleOpen="handleOpen" />
    1
    <!-- 内容 -->
    <div class="content">
      <router-view :key="index"></router-view>
    </div>
    <!-- 底部 -->
    <div class="footer">
      <!-- 底部内容 -->
      <div class="contain">
        <div class="rows">
          <div class="leftName">联&ensp;系&ensp;人：</div>
          <div class="rightCnt">刘先生</div>
        </div>
        <div class="rows">
          <div class="leftName">联系电话：</div>
          <div class="rightCnt">155587974574</div>
        </div>
        <div class="rows">
          <div class="leftName">地&ensp;&ensp;&ensp;&ensp;址：</div>
          <div class="rightCnt">重庆市巴南区重庆工程学院内</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, onMounted, onBeforeUpdate } from "vue";
import Login from "@/components/modal/loginModal.vue";
import { useRouter } from "vue-router";
import LocalCatch from "@/utils/token";
import Loaded from "../default/default.vue";
import useLogin from "@/utils/statusManage.js";
import { download } from "@/service/api.js";
const router = useRouter();
// 搜索
const search = ref(null);
const open = ref(false);
// 页面加载变量
const isLoading = ref(true);
// myDetails Dom
const myDetails = ref();
//userid
const id = ref(null);
// 二级路由标识
const index = ref("");
// 待领养的猫
const adoptingCat = ref([]);
// 已经领养的猫
const adoptedCat = ref([]);
const { getIsLogin, setIsLogin } = useLogin();
onMounted(() => {
  isLoading.value = false;
});
// 获取可用的url
const load = async (name) => {
  if (name) {
    const res = await download({ name });
  }
};
const login = () => {
  open.value = true;
};

const handleOpen = (value) => {
  open.value = value;
};
// 登录信息显示
const handleMouseEnter = () => {
  myDetails.value.style.display = "block";
};
const handleMouseLeave = () => {
  myDetails.value.style.display = "none";
};
// 退出
const exit = () => {
  router.push({ name: "home" });

  LocalCatch.clearToken();
  setIsLogin(false);

  setIsLogin(0);
};

// 关于我们
const handleAbout = () => {
  router.push({ name: "about" });
};
//跳转到NavDetails
const toNavDetails = () => {
  router.push({ path: "/navDetails" });
};
//跳转到latestNews
const toLatestNews = () => {
  router.push({ path: "/navDetails/latestNews" });
};
// 领养须知
const tolAdoptMsg = () => {
  router.push({ path: "/navDetails/adoptMsg" });
};
//小常识
const tolCommonSense = () => {
  router.push({ path: "/navDetails/lcommonSense" });
};
//搜索
const handleSearch = async () => {
  router.push({ name: "search", query: { animalName: search.value } });
  index.value = search.value;
};
// 加载完成
// setTimeout(() => {
//   isLoading.value = false;
// }, 500);
</script>
<style scoped>
* {
  list-style: none;
}

li {
  display: inline;
}
.logo .title {
  position: relative;
  left: 45%;
  font-size: 35px;
  color: transparent;
  background-color: #333333;
  text-shadow: rgba(255, 255, 255, 0.5) 0 5px 6px,
    rgba(255, 255, 255, 0.2) 1px 3px 3px;
  -webkit-background-clip: text;
  .txt {
    font-size: 35px;
    color: transparent;
    background-color: #ff6347;
    text-shadow: rgba(255, 255, 255, 0.5) 0 5px 6px,
      rgba(255, 255, 255, 0.2) 1px 3px 3px;
    -webkit-background-clip: text;
  }
}
.header .headerImg {
  height: 35px;
  margin: 5px 10px;
  border-radius: 30px;
  position: absolute;
  right: 30%;
  cursor: pointer;
}

.header .myDetails {
  display: none;
  position: absolute;
  width: 280px;
  top: 38px;
  right: 23%;
  padding: 16px;
  z-index: 999;
  background-color: #e0dbd6;
}
.myDetails .noLogin {
  display: flex;
  flex-flow: row wrap;
  width: 100%;
}
.myDetails .noLogin .notice {
  display: flex;
  flex-flow: row wrap;
  width: 100%;
}
.myDetails .noLogin .notice .til {
  width: 100%;
  height: 22px;
  font-size: 14px;
  font-family: PingFangSC-Medium, PingFang SC;
  font-weight: 500;
  color: #222226;
  line-height: 22px;
  text-align: left;
}
.myDetails .noLogin .notice .til-a {
  width: 50%;
  font-size: 14px;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  color: #555666;
  height: 14px;
  line-height: 14px;
}

.myDetails .noLogin .notice .til-b {
  display: inline-block;
  position: relative;
  width: 16px;
  height: 16px;
  margin-right: 8px;
  vertical-align: middle;
  top: -1px;
  background-repeat: no-repeat;
  background-size: contain;
}
.myDetails .noLogin span {
  display: block;
  margin: 0 auto 8px;
  width: 336px;
  height: 40px;
  line-height: 40px;
  background: #423834;
  border-radius: 20px;
  text-align: center;
  font-size: 14px;
  font-family: PingFangSC-Medium, PingFang SC;
  font-weight: 500;
  color: #fff;
  cursor: pointer;
}
.myDetails .logined {
  width: 100%;
  display: flex;
  flex-flow: column nowrap;
  justify-content: space-between;
}
.myDetails .logined a {
  color: #213547;
  padding-bottom: 10px;
}
.myDetails .logined h2 {
  text-align: center;
  width: 100%;
  font-size: 18px;
  color: #222226;
  font-weight: 500;
  height: 40px;
  line-height: 40px;
}
.myDetails .logined img {
  width: 30px;
  height: 25px;
}
.nav .menu2 p {
  margin-bottom: 0;
}
.nav ul li .items {
  transition: all 0.2s ease;
  font-weight: 500;
  color: #fceae2;
  text-decoration: inherit;
}
.wrap {
  width: 100%;
  display: flex;
  flex-flow: column nowrap;
  justify-content: flex-start;
  align-items: center;
  flex: 1;
  background: linear-gradient(#ffded9, 10%, #ffe4e1);
}

.header {
  display: flex;
  flex-flow: column nowrap;
  align-items: center;
  width: 100%;
}
.header .container1 {
  display: flex;
  flex-flow: wrap nowrap;
  justify-content: flex-end;
  width: 1000px;
}
.header .container1 img:hover .myDetails {
  display: block;
}
.header .container2 {
  width: 1000px;
  display: flex;
  flex-flow: row nowrap;
  justify-content: space-between;
  align-items: center;
}
.header .container2 .search {
  width: 285px;
  height: 65px;
  line-height: 65px;
}
.header .container2 .search .text {
  height: 40px;
  padding: 8px 16px;
  background: #fff;
  width: 220px;
  border: 0;
  outline: 0;
  top: 3px;
  border-top-left-radius: 20px;
  border-bottom-left-radius: 20px;
}
.header .container2 .search .searchBtn {
  height: 40px;
  width: 65px;
  padding: 8px 17px;
  border-top-right-radius: 20px;
  border-bottom-right-radius: 20px;
  background-color: #423834;
  cursor: pointer;
}
/* 导航 */
.wrap .container {
  display: flex;
  flex-flow: row nowrap;
  justify-content: center;
  margin-top: 10px;
  height: 40px;
  width: 100%;
}
.container .nav {
  width: 1000px;
  height: 40px;
  line-height: 40px;
  background: #423834;
  border-radius: 20px;
  -webkit-border-radius: 20px;
  background-color: #423834;
}

.nav li {
  float: left;
  text-align: center;
  padding: 0 21px;
}
/* 二级菜单 */
.nav .menu2 {
  display: none;
  z-index: 999;
  position: absolute;
  width: 117px;
  left: 373px;
  top: 154px;
  background-color: #eec591;
  cursor: pointer;
}
.nav li:hover {
  background-color: #ff8c00;
}
/* 二级菜单伪类 */
.nav .about:hover .crow {
  transform: rotate(180deg);
}

.nav .about:hover .menu2 {
  display: block;
}
.menu2 p:hover {
  background-color: #ffd39b;
}
/* 箭头 */
.nav .crow {
  width: 0;
  height: 0;
  /*background: white;*/
  border: 5px solid transparent;
  border-top: 5px solid #ffffff;
  display: inline-block;
  position: relative; /*相对于初始位置进行定位 */
  top: 3px;
  left: 8px;
  /*设置所有动画的效果：0.1s 淡出效果*/
  transition: all 0.1s ease-out;
  /* 设置旋转中心 */
  transform-origin: 50% 25%; /**x y */
}
/* 内容 */
.content {
  display: flex;
  flex-flow: column nowrap;
  justify-content: flex-start;
  align-items: center;
  flex: 1;
  width: 100%;
  margin-top: 30px;
  /* border: 1px solid red; */
}
.content .partOne,
.content .container-pTwo {
  display: flex;
  flex-flow: row wrap;

  width: 1000px;
}
.content .partOne .adoptionNotice {
  position: relative;
  top: -24px;
}
.content .partOne .adoptionNotice .cnt-bottom {
  height: 135px;
  overflow: hidden;
  background: #e0dbd6;
  padding: 10px 18px;
  font-size: 13px;
  color: #423834;
  line-height: 24px;
}
.content .partOne .partOne-right {
  display: flex;
  flex-flow: column nowrap;
  justify-content: space-between;
  overflow: hidden;
  padding-left: 30px;
  height: 400px;
  width: 523px;
}
.partOne .partOne-right .latestNwes .title {
  font-size: 18px;
  color: #423834;
  border-bottom: 1px solid #d4d0cd;
  line-height: 30px;
}
.partOne .partOne-right .latestNwes .box {
  padding-top: 10px;
  border-top: 1px solid #fbf6f1;
}
.partOne .partOne-right .latestNwes .box .cnt {
  height: 144px;
  overflow: hidden;
  background: #e0dbd6;
  padding: 10px 18px;
  font-size: 13px;
  color: #423834;
  line-height: 24px;
}
.latestNwes .title .tit {
  border-bottom: 3px solid #665843;
  position: relative;
  bottom: 1px;
  padding-bottom: 3px;
}
.cnt .more,
.cnt-bottom .more {
  color: #c57b5d;
  font-size: 13px;
  cursor: default;
}
.more-black {
  font-size: 14px;
  color: #423834;
  float: right;
  position: relative;
  bottom: -18px;
  cursor: pointer;
}
.content .partOne .picScroll {
  position: relative;
  float: left;
  width: 477px;
  height: 375px;
  background: url("@/imgs/picBg.jpg") no-repeat;
}
.content .partTwo {
  padding-top: 25px;
}
.content .partTwo .container-pTwo .title-pTwo {
  border-bottom: 1px solid #d4d0cd;
  width: 1000px;
  height: 45px;
}
.partTwo .title-pTwo .fl {
  font-size: 18px;
  color: #423834;
  float: left;
}
.partTwo .title-pTwo .fl img {
  width: 37px;
  height: 44.4px;
  margin-right: 6px;
  display: inline-block;
  vertical-align: middle;
  border-bottom: 3px solid #665843;
  padding-bottom: 5px;
  position: relative;
  bottom: -2px;
}

.partTwo .container-pTwo ul .first {
  display: flex;
  flex-flow: column nowrap;
  float: left;
  margin-left: 6px;
  width: 185px;
  padding: 5px;
}
.partTwo .container-pTwo ul .first .txt {
  display: flex;
  flex-flow: row wrap;
  justify-content: space-between;
  margin-top: 5px;
  width: 182px;
  padding: 5px;
  font-size: 14px;
}
.partTwo .container-pTwo ul .first .txt .details {
  display: flex;
  flex-flow: row wrap;
  width: 182px;
  padding-left: 2px;
}
.partTwo .container-pTwo ul .first .txt .details span {
  width: 85px;
}
.content .partOne .picScroll .newsTip {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 2;
}
.clr {
  zoom: 1;
}
.content .partOne .picScroll .scrollCnt {
  margin: 23px 27px 0 27px;
  width: 425px;
  height: 352px;
  overflow: hidden;
  position: relative;
}
.content .partOne .picScroll .scrollCnt .msg {
  position: relative;
  z-index: 9;
}
.content .partThree {
  display: flex;
  flex-flow: row nowrap;
  justify-content: center;
  padding-top: 25px;
}
.content .partThree .container-three {
  width: 1000px;
  display: flex;
  flex-flow: row nowrap;
  justify-content: space-between;
}
.content .partThree .container-three .tips,
.aboutUs {
  width: 478px;
  display: flex;
  flex-flow: column nowrap;
  justify-content: flex-start;
}
.content .partThree .container-tree .title-three {
  font-size: 18px;
  color: #423834;
  border-bottom: 1px solid #d4d0cd;
  line-height: 30px;
}
.content .partThree .container-three .title-three span {
  border-bottom: 3px solid #665843;
  position: relative;
  bottom: 1px;
  padding-bottom: 3px;
}
.content .partThree .container-three .box-three {
  padding-top: 10px;
  border-top: 1px solid #fbf6f1;
}
.content .partThree .container-three .cnt-three {
  overflow: hidden;
  background: #e0dbd6;
  padding: 10px 18px;
  font-size: 13px;
  color: #423834;
  line-height: 24px;
}

/* 底部 */
.footer {
  display: flex;
  flex-flow: column nowrap;
  justify-content: flex-start;
  align-items: center;
  height: 291px;
  width: 100%;
  margin-top: 55px;
  padding: 30px 0;
  color: #d1b3a6;
  font-size: 16px;
  background: #37302d;
}
.footer .contain {
  display: flex;
  flex-flow: column nowrap;
  justify-content: flex-start;
  width: 1000px;
}
.footer .contain .rows {
  padding-bottom: 20px;
  zoom: 1;
  display: flex;
  flex-flow: row nowrap;
}

.footer .contain .rows .leftName {
  color: #7e6e68;
  float: left;
  width: 80px;
}
.footer .contain .rows .rightCnt {
  overflow: hidden;
  line-height: 23px;
  width: 750px;
  margin-left: 20px;
}

:deep(.slick-slide) {
  text-align: center;
  height: 300px;
  line-height: 300px;
  overflow: hidden;
}
:deep(.slick-slide h3) {
  color: #fff;
}
</style>
